{template '_header'}
<div class="page-heading">
	<h2>分类管理</h2>
</div>
<div class="alert alert-info">提示: 排序数字越大越靠前; 如果设置该分类不显示则消息列表中不会出现此类文章;</div>
<form action="{php echo webUrl('article/category/save')}" method="post" class="form-validate">

	<table class="table table-hover  table-responsive">
		<thead class="navbar-inner">
			<tr>
				<th style="width:60px;">ID</th>
				<th style="width:60px;">排序</th>
				<th>分类名称</th>
				<th style="width:60px;">显示</th>
				<th style="width:80px;">操作</th>
			</tr>
		</thead>
		<tbody id='tbody-items'>
			{loop $list $row}
			<tr>
				<td>
					{$row['id']}
				</td>
				<td>
					{ifp 'article.category.edit'}
						<input type="text" class="form-control" name="cate[{$row['id']}][displayorder]" value="{$row['displayorder']}"> 
					{else}
						{$row['displayorder']} 
					{/if}
				</td>
				<td>
					{ifp 'article.category.edit'}
						<input type="text" class="form-control" name="cate[{$row['id']}][name]" value="{$row['category_name']}"> 
					{else} 
						{$row['name']} 
					{/if}
				</td>
				<td>
					{ifp 'article.category.edit'}
						<input type="checkbox" name="cate[{$row['id']}][isshow]" value="1" {if !empty($row['isshow'])} checked="checked"{/if}>
					{else}
						{php echo !empty($row['isshow'])?'是':'否'}
					{/if}
				</td>
				<td>
					{ifp 'article.category.edit'}
						<a data-toggle="ajaxRemove" href="{php echo webUrl('article/category/delete', array('id' => $row['id']))}" class="btn btn-default btn-sm" data-confirm="确认删除此分类?">
						<i class="fa fa-trash"></i> 删除</a>
					{/if}
				</td>
				</td>
			</tr>
			{/loop}
		</tbody>

		<tr>
			<td colspan="5">
				{ifp 'article.category.edit'}
					<input type="button" class="btn btn-default" value="添加分类" onclick='addCategory()'> 
				{/if} 
				{ifp 'article.category.edit'}
					<input type="submit" class="btn btn-primary" value="保存分类"> 
				{/if}
			</td> 
		</tr>
	</table>
	{$pager}

</form>

{ifp 'article.category.edit'}
	<script>
		function addCategory() {
			var html = '<tr>';
			html += '<td><i class="fa fa-plus"></i></td>';
			html += '<td></td>';
			html += '<td>';
			html += '<input type="text" class="form-control" name="cate_new[]" value="">';
			html += '</td>';
			html += '<td></td>';
			html += '<td></td></tr>';;
			$('#tbody-items').append(html);
		}
	</script>
{/if}

{template '_footer'}